package com.icinfo.cloud.provider.common.utils;

import com.icinfo.cloud.provider.common.annotation.CheckDate;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 描述：日期校验器
 *
 * @author xiangyuyu
 * @date 2022-02-22 18:34
 */
public class DateValidator implements ConstraintValidator<CheckDate, String> {

    private String format;

    @Override
    public void initialize(CheckDate constraintAnnotation) {
        this.format = constraintAnnotation.format();
    }

    @Override
    public boolean isValid(String object, ConstraintValidatorContext constraintContext) {

        return TimeValidator.validator(object, format);
    }
}